home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / kaffe-0.2 / lib / native / java.lang / java.lang.Runtime.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-19  |  2.7 KB  |  140 lines

  1. /*
  2.  * java.lang.Runtime.c
  3.  *
  4.  * Copyright (c) 1996 Systems Architecture Research Centre,
  5.  *           City University, London, UK.
  6.  *
  7.  * See the file "license.terms" for information on usage and redistribution
  8.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9.  *
  10.  * Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include <assert.h>
  15. #include <native.h>
  16. #include "defs.h"
  17. #include "files.h"
  18. #include "java.lang.Runtime.h"
  19.  
  20. extern char* getLibraryPath();
  21.  
  22. /*
  23.  * Initialise the linker and return the search path for shared libraries.
  24.  */
  25. struct Hjava_lang_String*
  26. java_lang_Runtime_initializeLinkerInternal(struct Hjava_lang_Runtime* this)
  27. {
  28.     char* libraryPath;
  29.  
  30.     libraryPath = getLibraryPath();
  31.     return (makeJavaString(libraryPath, strlen(libraryPath)));
  32. }
  33.  
  34. /*
  35.  * Construct a library name.
  36.  */
  37. struct Hjava_lang_String*
  38. java_lang_Runtime_buildLibName(struct Hjava_lang_Runtime* this, struct Hjava_lang_String* s1, struct Hjava_lang_String* s2)
  39. {
  40.     char lib[MAXLIBPATH];
  41.     char str[MAXPATHLEN];
  42.  
  43.     javaString2CString(s1, str, sizeof(str));
  44.     strcpy(lib, str);
  45.     strcat(lib, "/lib");
  46.     javaString2CString(s2, str, sizeof(str));
  47.     strcat(lib, str);
  48.     strcat(lib, ".so");
  49.  
  50.     return (makeJavaString(lib, strlen(lib)));
  51. }
  52.  
  53. /*
  54.  * Load in a library file.
  55.  */
  56. long /* bool */
  57. java_lang_Runtime_loadFileInternal(struct Hjava_lang_Runtime* this, struct Hjava_lang_String* s1)
  58. {
  59.     char lib[MAXPATHLEN];
  60.     int r;
  61.  
  62.     javaString2CString(s1, lib, sizeof(lib));
  63.     r = loadNativeLibrary(lib);
  64.  
  65.     return (r == 0 ? 1 : 0);
  66. }
  67.  
  68. /*
  69.  * Exit - is this just a thread or the whole thing?
  70.  */
  71. void
  72. java_lang_Runtime_exitInternal(struct Hjava_lang_Runtime* r, long v)
  73. {
  74.     exit (v);
  75. }
  76.  
  77. /*
  78.  * Exec another program.
  79.  */
  80. struct Hjava_lang_Process*
  81. java_lang_Runtime_execInternal(struct Hjava_lang_Runtime* this, HArray* args, HArray* envs)
  82. {
  83.     abort();
  84. }
  85.  
  86. /*
  87.  * Free memory.
  88.  */
  89. long long java_lang_Runtime_freeMemory(struct Hjava_lang_Runtime* this)
  90. {
  91.     abort();
  92.     return (0);
  93. }
  94.  
  95. /*
  96.  * Total memory.
  97.  */
  98. long long
  99. java_lang_Runtime_totalMemory(struct Hjava_lang_Runtime* this)
  100. {
  101.     return (0);
  102. }
  103.  
  104. /*
  105.  * Run the garbage collector.
  106.  */
  107. void
  108. java_lang_Runtime_gc(struct Hjava_lang_Runtime* this)
  109. {
  110.     invokeGarbageCollector();
  111. }
  112.  
  113. /*
  114.  * Run any pending finialized methods.
  115.  *  Finalising is part of the garbage collection system - so just run that.
  116.  */
  117. void
  118. java_lang_Runtime_runFinalization(struct Hjava_lang_Runtime* this)
  119. {
  120.     invokeGarbageCollector();
  121. }
  122.  
  123. /*
  124.  * Enable/disable tracing of instructions.
  125.  */
  126. void
  127. java_lang_Runtime_traceInstructions(struct Hjava_lang_Runtime* this, long on)
  128. {
  129.     abort();
  130. }
  131.  
  132. /*
  133.  * Enable/disable tracing of method calls.
  134.  */
  135. void
  136. java_lang_Runtime_traceMethodCalls(struct Hjava_lang_Runtime* this, long on)
  137. {
  138.     abort();
  139. }
  140.